import request from '@/utils/request'

// 分页定义管理
export function fetchList(query) {
  query = {
    'processDefinitionQuery': {
      'modelKey': query.modelKey,
      'name': query.name
    },
    'query': {
      pageNum: query.pageNum,
      pageSize: query.pageSize
    }
  }
  return request({
    url: '/rest/definition/page-model',
    method: 'post',
    data: query
  })
}

// 定义管理 XML
export function processFileXml(id) {
  return request({
    url: '/rest/definition/processFile/xml/' + id,
    method: 'get'
  })
}

// 定义管理 流程图
export function processFileImg(id) {
  return request({
    url: '/rest/definition/processFile/img/' + id + '?t=' + Date.parse(new Date()),
    method: 'get'
  })
}

/**
 * 定义管理 挂起（激活）
 * id ID
 * suspensionState 状态 1-挂起 2-激活
 * @param {*} query
 */
export function saDefinitionById(query) {
  return request({
    url: '/rest/definition/saDefinitionById',
    method: 'post',
    params: query
  })
}

/**
 * 定义管理 删除
 * deploymentId ID
 * @param {*} query
 */
export function deleteDeployment(query) {
  return request({
    url: '/rest/definition/deleteDeployment',
    method: 'post',
    params: query
  })
}
